/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package siteanaliz;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.table.*;
/**
 *
 * @author Никита
 */
public class Top3 extends JDialog {
    private static final int D_WIDTH=500;
    private static final int D_HEIGHT=300;
    private JTable table;
    JLabel c;
    public  Top3(JFrame owner, String lang, String SE, String tag, int poses)
    {
        super(owner,"Potential concurents",true);
        setSize(D_WIDTH,D_HEIGHT);
        c=new JLabel("<html><h1><i>Your potential concurents</i></h1><hr> Options: SE="+SE+", KEY="+tag+", Lang="+lang+"</html>");
        JPanel DPanel = new JPanel();
        GridBagConstraints propert;
        GridBagLayout layout = new GridBagLayout(); 
        propert = new GridBagConstraints();
         propert.gridx = 2;
         propert.gridy = 2;
         propert.insets = new Insets(5,10, 0, 0);
         layout.setConstraints(c, propert);
         
          DPanel.setLayout(layout);
          DPanel.add(c);
           table = new JTable(new DefaultTableModel(new Object[][]{},
            new String[]{"Site", "URL"})
            {
           public boolean isCellEditable(int row, int column)
           {
                return false;
           }
            });
         
            JScrollPane SP=new JScrollPane(table);
            SP.setPreferredSize(new Dimension( table.getPreferredScrollableViewportSize().width,
             6 * table.getRowHeight()));

           final JPanel ResultPanel = new JPanel();
           ResultPanel.setBorder(BorderFactory.createTitledBorder("Top3"));
          ResultPanel.setLayout(new BorderLayout());
          ResultPanel.add(SP,BorderLayout.CENTER);
          propert = new GridBagConstraints();
         propert.gridx = 2;
         propert.gridy = 3;
         propert.insets = new Insets(5,10, 0, 0);
         layout.setConstraints( ResultPanel, propert);
          DPanel.add(ResultPanel);
        //add(new JLabel("<html><h1><i>Your potential concurents</i></h1><hr> For your keyword:</html>"),BorderLayout.NORTH);
        //c=new JLabel("Loading...");
       // add(c);
        Top3Runnable rn=new Top3Runnable(lang, DPanel,layout,table, SE, poses, tag );
        Thread th=new Thread(rn);
        th.setName("T1");
        th.start();
        JButton ok=new JButton("Ok");
        ok.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent event)
            {
                setVisible(false);
            }
        });    
         JPanel DPanel2 = new JPanel();
        GridBagConstraints propert1;
        GridBagLayout layout2 = new GridBagLayout(); 
        propert1 = new GridBagConstraints();
         propert1.gridx = 2;
         propert1.gridy = 2;
         propert1.insets = new Insets(5,10, 20, 0);
         layout2.setConstraints(ok, propert1);
          
          DPanel2.setLayout(layout2);
          DPanel2.add(ok);
       
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(DPanel, BorderLayout.NORTH);
         getContentPane().add(DPanel2, BorderLayout.SOUTH);
      
    }
}
